/**
 * Definition for singly-linked list.
 * function ListNode(val) {
 *     this.val = val;
 *     this.next = null;
 * }
 */
/**
 * @param {ListNode} head
 * @param {number} val
 * @return {ListNode}
 */
var deleteNode = function(head, val) {
	let pre = new ListNode(-1); // 哨兵节点
	pre.next = head;

	let node = pre;
	while (node.next) {
		if (node.next.val === val) {
		// 将要删除的节点的前一个节点的 next 指向要删除节点的后一个节点
			node.next = node.next.next;
			break;
		}
		node = node.next;
	}
	return pre.next
};